﻿using UnityEngine;
using System.Collections;

public class FacebookSignUpButton : MonoBehaviour {

	// Use this for initialization
	void Start () {
        if (FB.IsLoggedIn)
            this.gameObject.SetActive(false);
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void OnClick()
	{
		FacebookManager.Login(LoginCallback);
		this.gameObject.SetActive(false);
	}
	
	void LoginCallback(bool isSuccess)
	{
		if( !FB.IsLoggedIn )
			this.gameObject.SetActive(true);
        if (MyInfo.Instance.DBID != 0 && CSceneManager.m_Scene != SCENE.CharacterSelectScene)
        {
            LoadingWindow.window.ShowShortLoading();
            RestAPI.singleton.SendFacebookInfo(ReturnCallback, false);
        }
	}

    void ReturnCallback(Hashtable returnData)
    {
        LoadingWindow.window.HideLoading();
    }
}
